package com.usian.behavior.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.usian.behavior.mapper.ApBehaviorEntryMapper;
import com.usian.behavior.service.ApBehaviorEntryService;
import com.usian.model.behavior.pojos.ApBehaviorEntry;
import com.usian.model.common.base.BaseServiceImpl;
import org.springframework.stereotype.Service;

@Service
public class ApBehaviorEntryServiceImpl extends BaseServiceImpl<ApBehaviorEntryMapper, ApBehaviorEntry> implements ApBehaviorEntryService {
    @Override
    public ApBehaviorEntry findByUserIdOrEquipmentId(Integer userId, Integer equipmentId) {
        if (userId == null && equipmentId == null && userId != -1 && equipmentId != -1) return null;
        return getOne(Wrappers.<ApBehaviorEntry>lambdaQuery().eq(ApBehaviorEntry::getEntryId, userId != null ? userId : equipmentId).eq(ApBehaviorEntry::getType, userId != null ? 1 : 0));

    }
}
